#include "TestEvents.h"

#include "BasicEvent.h"
#include "FileEvent.h"
#include "OutputConfig.h"
#include "AbpaFileFormat.h"

#include <fstream>

using namespace events;

void TestEvents::CreateEventsFile(void)
{
	std::cout << "Saving some events...\n";

	config::OutputConfig conf;
	platform::XString fname = conf.getProcessOutputFile(_T("abpa"));

	std::ofstream out(fname.c_str());
	if (!out.is_open()) {
		std::cout << "Faield to open file for output\n";
		return;
	}

	AbpaFileFormat aff;
	aff.saveAbpaHeader(out);	

	BasicEvent *e1 = new FileEvent(FileEvent::FE_OPEN);
	static_cast<FileEvent*>(e1)->setFileName(L"c:\\temp\\file.txt");

	BasicEvent *e2 = new FileEvent(FileEvent::FE_READ);
	BasicEvent *e3 = new FileEvent(FileEvent::FE_CLOSE);

	out << (*e1) << (*e2) << (*e3);

	delete e3;
	delete e2;
	delete e1;

}